Imports System.Drawing
Imports System.Drawing.Drawing2D

Public Class TriangleGradientBrush

    Private Sub TriangleGradientBrush_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub TriangleGradientBrush_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
        Dim cx As Integer = Me.Width
        Dim cy As Integer = Me.Height
        'Dim apt As Point() = {New Point(cx, 0), New Point(cx, cy), New Point(0, cy)}
        'Dim pgbrush As PathGradientBrush = New PathGradientBrush(apt)
        'e.Graphics.FillRectangle(pgbrush, 0, 0, cx, cy)

        Dim apt() As Point = New Point(5) {}

        Dim i As Integer
        For i = 0 To apt.Length - 1 
            Dim dAngle As Double = (i * 0.8 - 0.5) * Math.PI
            apt(i) = New Point(CType((cx * (0.5 + 0.48 * Math.Cos(dAngle))), Integer), CType((cy * (0.5 + 0.48 * Math.Sin(dAngle))), Integer))
        Next
        Dim pgbrush As PathGradientBrush = New PathGradientBrush(apt)

        pgbrush.CenterColor = Color.White
        Dim aColor As Color() = {Color.Black}
        pgbrush.SurroundColors = aColor

        e.Graphics.FillRectangle(pgbrush, 0, 0, cx, cy)

    End Sub
End Class